import os
from time import sleep
from base.base import Base
import page


class PageAppSniffing(Base):

    # 点击首页
    def __page_app_click_no_browser_index(self):
        # sleep(1)
        self.base_click(page.app_sniffing_no_browser_index)

    # 输入框输入
    def __page_app_sniffing_no_browser_input(self,link_url):
        # sleep(1)
        self.base_input(page.app_sniffing_no_browser_input,link_url)

    # 点击下载
    def __page_app_sniffing_no_browser_download(self):
        # sleep(1)
        self.base_click(page.app_sniffing_no_browser_download)

    # 关闭选择资源弹窗
    def __page_app_sniffing_no_browser_close(self):
        # sleep(1)
        self.base_click(page.app_sniffing_no_browser_close)

    # 最近下载-点击资源右上角按钮
    def __page_app_sniffing_no_browser_open_menu(self):
        self.base_click(page.app_sniffing_no_browser_open_menu)

    # 最近下载-点击菜单-删除
    def __page_app_sniffing_no_browser_menu_delete(self):
        delete_btn = self.base_finds(page.app_sniffing_no_browser_menu_delete)[-1]
        delete_btn.click()

    # 最近下载-点击删除二次确认
    def __page_app_sniffing_no_browser_open_menu_delete_ok(self):
        self.base_click(page.app_sniffing_no_browser_menu_delete_ok)


    # 组合业务方法-删除下载的资源
    def page_delete_data(self):
        # 点击最近下载更多菜单
        self.__page_app_sniffing_no_browser_open_menu()
        # 点击删除按钮
        self.__page_app_sniffing_no_browser_menu_delete()
        # 删除二次确认
        self.__page_app_sniffing_no_browser_open_menu_delete_ok()


    # 组合业务方法-手动点击下载
    def page_sniffing(self,link_url):
        # 点击首页
        self.__page_app_click_no_browser_index()
        # 输入框输入
        self.__page_app_sniffing_no_browser_input(link_url)
        # 点击下载
        self.__page_app_sniffing_no_browser_download()


    # 查找选择弹窗关闭按钮
    def page_find_close(self):
        return self.base_find(page.app_sniffing_no_browser_close)

    # 查找选择弹窗复选框按钮
    def page_find_checkall(self):
        return self.base_find(page.app_sniffing_no_browser_checkall)



